import numpy as np
import matplotlib.pyplot as plt

np.random.seed(2)
plt.figure(figsize=[16, 12])
spr = 6  # subplot rows
spc = 20  # subplot columns
spn = 0  # number of subplot

data = np.loadtxt(r'../../../../large_data/hand_writing/imgX.txt', delimiter=',')
print(data.shape)
m = len(data)
y = np.loadtxt(r'../../../../large_data/hand_writing/labely.txt', delimiter=',')
rnd_idx = np.random.permutation(m)
data = data[rnd_idx]
y = y[rnd_idx]

for i in range(0, spr * spc):
    spn += 1
    plt.subplot(spr, spc, spn)
    plt.title(y[i])
    img_data = data[i].reshape(20, 20).T
    plt.imshow(img_data)

plt.show()
